﻿using MainInterface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace MainFrameProperty
{
    public class UIEvent : IComponentXml, IBuilder
    {
        public string Name { get; set; }
        public string ChinaName { get; set; }
        public string Description { get; set; }
        public Dictionary<string, string> Args = new Dictionary<string, string>();
        public string Value { get; set; }
        public void LoadXmlZYK(System.Xml.XmlNode Node)
        {
            XmlAttribute attr = Node.Attributes["Name"];
            this.Name = attr.Value;
            attr = Node.Attributes["ChinaName"];
            this.ChinaName = attr.Value;
            attr = Node.Attributes["Description"];
            this.Description = attr.Value;
            foreach (XmlNode item in Node.ChildNodes)
            {
                string argname = item.Attributes["Name"].Value;
                string argdescription = item.Attributes["Description"].Value;
                if (!Args.ContainsKey(argname)) 
                {
                    Args.Add(argname, argdescription);
                }
            }
        }

        public void GetXml(System.Xml.XmlDocument doc, System.Xml.XmlNode Parent)
        {
            throw new NotImplementedException();
        }

        public void LoadUI(System.Xml.XmlNode node)
        {
            throw new NotImplementedException();
        }

        public string GetDom(string dom)
        {
            throw new NotImplementedException();
        }

        public string GetCSS(string style)
        {
            throw new NotImplementedException();
        }

        public string GetScript(string script)
        {
            if (string.IsNullOrEmpty(Value)) 
            {
                return string.Empty;
            }
            return "obj." + this.Name + "=function(" + string.Join(",", this.Args.Keys.ToArray()) + "){" + this.Value + "};";
        }

        public string GetReferences(string reference)
        {
            throw new NotImplementedException();
        }

        public string GetLinks(string links)
        {
            throw new NotImplementedException();
        }

        public void GetFiles(List<string> files)
        {
            throw new NotImplementedException();
        }
    }
}
